package com.example.web.controller;

import com.example.model.Department;
import com.example.web.swagger.IDepartmentController;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

@RestController
public class DepartmentController implements IDepartmentController {

    @GetMapping("/departments/list")
    public List<Department> list() {
        return Arrays.asList(
                new Department(1L, "hello", "world"),
                new Department(2L, "good", "bye")
        );
    }

    @GetMapping("/departments/get")
    public Department getDepartment(@RequestParam("id") Long id) {
        return new Department(1L, "hello", "world");
    }

    @PostMapping("/department/add")
    public Map<String, Object> addDepartment(Department department, @RequestParam("aaa") String aaa, @RequestParam("bbb") String bbb) {
        System.out.println(department);
        System.out.println(aaa);
        System.out.println(bbb);

        Map<String, Object> map = new LinkedHashMap<>();
        map.put("code", 10000);
        map.put("msg", "success");
        return map;
    }
}
